﻿Imports System.ComponentModel
Imports System.Drawing

Public Class RCMS_Preferences
    ' Preferences added here must also implement a property further down, tagged with PropertyGrid attributes,
    ' and must be replicated in the RCMS_Preferences_Serial class (private class members, SavePreferences and LoadPreferences).
    ' Preferences in the section below must have a default value assigned.
    ' If adding layer and/or colour, also add a line to CLDS_ColourLayerByPrefs so that layer is updated when preferences are saved.
#Region "Private declarations"
    Private v_file As String = ""                               ' Preferences XML file name
    Private v_g_clds As String = "RCMS Layer Group"             ' Layer group name
    Private v_b_wp As String = "WP-RCMS"                        ' WP block name
    Private v_l_wp As String = "CLDS_WP"                        ' WP layer
    Private v_c_wp As Color = Color.FromArgb(0, 255, 255)       ' WP layer colour
    Private v_f_wp As Integer = 50                              ' WP block scale factor
    Private v_t_wpid As String = "WP#"                          ' WP ID tag in block
    Private v_t_flor As String = "FLOOR#"                       ' WP floor tag in block
    Private v_t_room As String = "ROOM#"                        ' WP room tag in block
    Private v_t_fpno As String = "FP#"                          ' WP FP no tag in block
    Private v_t_fpid As String = "FPID"                         ' WP FP ID tag in block
    Private v_t_cbid As String = "CBID"                         ' WP cable ID tag prefix in block
    Private v_x_cbno As Integer = 10                            ' Max cable IDs per WP
    Private v_b_zone As String = "ZONE"                         ' Zone block name
    Private v_l_zone As String = "CLDS_WP"                      ' Zone layer
    Private v_c_zone As Color = Color.FromArgb(0, 255, 255)     ' Zone layer colour
    Private v_f_zone As Integer = 50                            ' Zone block scale factor
    Private v_t_zone As String = "ZONE"                         ' Zone ID tag in block
    Private v_l_grid As String = "CLDS_WP"                      ' Grid layer
    Private v_w_grid As Double = 4                              ' Grid width
    Private v_h_grid As Double = 3                              ' Grid row height
    Private v_c_grid As Double = 3                              ' Grid column width
    Private v_m_grid As Double = 1.5                            ' Grid horizontal margin
    Private v_v_grid As Double = 0.8                            ' Grid vertical margin
    Private v_t_grid As Double = 1                              ' Grid text height
    Private v_x_vist As String = ""                             ' Interface version string
    Private v_x_v9st As String = ""                             ' V9 rule-set version string
    Private v_x_timo As Integer = 120                           ' CMPIC API timeout (seconds)
    Private v_b_wpb As String = "WP-B"                          ' Legacy WP block name
    Private v_b_wpl As String = "WP-L"                          ' Legacy WP block name
    Private v_b_wpr As String = "WP-R"                          ' Legacy WP block name
    Private v_b_wpt As String = "WP-T"                          ' Legacy WP block name
    Private v_b_wpd As String = "WP-D"                          ' Legacy WP block name
    Private v_d_xrec As String = "CLDS_RCMS"                    ' Entity XRecord name and XData registered app name
    Private v_p_excl As String = "%USERPROFILE%"                ' Excel report output path
    Private v_c_texc As Color = Color.FromArgb(23, 55, 93)      ' Title colour
    Private v_c_hexc As Color = Color.FromArgb(184, 204, 228)   ' Header colour
#End Region
#Region "WP preferences"
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Block name"), _
       DescriptionAttribute("Name of block representing WP")> _
    Public Property b_wp() As String
        Get
            Return v_b_wp
        End Get
        Set(ByVal value As String)
            v_b_wp = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Block scale factor"), _
       DescriptionAttribute("Scale factor to apply during block insertion")> _
    Public Property f_wp() As String
        Get
            Return v_f_wp
        End Get
        Set(ByVal value As String)
            v_f_wp = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Layer name"), _
       DescriptionAttribute("Name of layer for WPs")> _
    Public Property l_wp() As String
        Get
            Return v_l_wp
        End Get
        Set(ByVal value As String)
            v_l_wp = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Layer colour"), _
       DescriptionAttribute("Colour of WP layer")> _
    Public Property c_wp() As Color
        Get
            Return v_c_wp
        End Get
        Set(ByVal value As Color)
            v_c_wp = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("WP ID tag"), _
       DescriptionAttribute("Tag of ID attribute in WP block")> _
    Public Property t_wpid() As String
        Get
            Return v_t_wpid
        End Get
        Set(ByVal value As String)
            v_t_wpid = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Floor tag"), _
       DescriptionAttribute("Tag of floor attribute in WP block")> _
    Public Property t_flor() As String
        Get
            Return v_t_flor
        End Get
        Set(ByVal value As String)
            v_t_flor = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Room tag"), _
       DescriptionAttribute("Tag of room attribute in WP block")> _
    Public Property t_room() As String
        Get
            Return v_t_room
        End Get
        Set(ByVal value As String)
            v_t_room = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("FP no tag"), _
       DescriptionAttribute("Tag of FP number attribute in WP block")> _
    Public Property t_fpno() As String
        Get
            Return v_t_fpno
        End Get
        Set(ByVal value As String)
            v_t_fpno = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("FP ID tag"), _
       DescriptionAttribute("Tag of FP ID attribute in WP block")> _
    Public Property t_fpid() As String
        Get
            Return v_t_fpid
        End Get
        Set(ByVal value As String)
            v_t_fpid = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Cable ID tag prefix"), _
       DescriptionAttribute("Prefix for cable ID attribute tags in WP block")> _
    Public Property t_cbid() As String
        Get
            Return v_t_cbid
        End Get
        Set(ByVal value As String)
            v_t_cbid = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Max cable IDs"), _
       DescriptionAttribute("Maximum number of cables per WP block")> _
    Public Property x_cbno() As Integer
        Get
            Return v_x_cbno
        End Get
        Set(ByVal value As Integer)
            v_x_cbno = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Legacy WP block"), _
       DescriptionAttribute("Legacy WP block")> _
    Public Property b_wpb() As String
        Get
            Return v_b_wpb
        End Get
        Set(ByVal value As String)
            v_b_wpb = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Legacy WP block"), _
       DescriptionAttribute("Legacy WP block")> _
    Public Property b_wpl() As String
        Get
            Return v_b_wpl
        End Get
        Set(ByVal value As String)
            v_b_wpl = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Legacy WP block"), _
       DescriptionAttribute("Legacy WP block")> _
    Public Property b_wpr() As String
        Get
            Return v_b_wpr
        End Get
        Set(ByVal value As String)
            v_b_wpr = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Legacy WP block"), _
       DescriptionAttribute("Legacy WP block")> _
    Public Property b_wpt() As String
        Get
            Return v_b_wpt
        End Get
        Set(ByVal value As String)
            v_b_wpt = value
        End Set
    End Property
    <CategoryAttribute("WP"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Legacy WP block"), _
       DescriptionAttribute("Legacy WP block")> _
    Public Property b_wpd() As String
        Get
            Return v_b_wpd
        End Get
        Set(ByVal value As String)
            v_b_wpd = value
        End Set
    End Property
#End Region
#Region "Zone preferences"
    <CategoryAttribute("Zone"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Block name"), _
       DescriptionAttribute("Name of block representing Zone")> _
    Public Property b_zone() As String
        Get
            Return v_b_zone
        End Get
        Set(ByVal value As String)
            v_b_zone = value
        End Set
    End Property
    <CategoryAttribute("Zone"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Block scale factor"), _
       DescriptionAttribute("Scale factor to apply during block insertion")> _
    Public Property f_zone() As String
        Get
            Return v_f_zone
        End Get
        Set(ByVal value As String)
            v_f_zone = value
        End Set
    End Property
    <CategoryAttribute("Zone"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Layer name"), _
       DescriptionAttribute("Name of layer for Zones")> _
    Public Property l_zone() As String
        Get
            Return v_l_zone
        End Get
        Set(ByVal value As String)
            v_l_zone = value
        End Set
    End Property
    <CategoryAttribute("Zone"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Layer colour"), _
       DescriptionAttribute("Colour of Zone layer")> _
    Public Property c_zone() As Color
        Get
            Return v_c_zone
        End Get
        Set(ByVal value As Color)
            v_c_zone = value
        End Set
    End Property
    <CategoryAttribute("Zone"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Zone tag"), _
       DescriptionAttribute("Tag of Zone ID attribute in Zone block")> _
    Public Property t_zone() As String
        Get
            Return v_t_zone
        End Get
        Set(ByVal value As String)
            v_t_zone = value
        End Set
    End Property
#End Region
#Region "Grid preferences"
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Layer name"), _
        DescriptionAttribute("Name of layer for number grid")> _
    Public Property l_grid() As String
        Get
            Return v_l_grid
        End Get
        Set(ByVal value As String)
            v_l_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Width"), _
        DescriptionAttribute("Grid width")> _
    Public Property w_grid() As Double
        Get
            Return v_w_grid
        End Get
        Set(ByVal value As Double)
            v_w_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Row height"), _
        DescriptionAttribute("Grid row height")> _
    Public Property h_grid() As Double
        Get
            Return v_h_grid
        End Get
        Set(ByVal value As Double)
            v_h_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Column width"), _
        DescriptionAttribute("Grid column width")> _
    Public Property c_grid() As Double
        Get
            Return v_c_grid
        End Get
        Set(ByVal value As Double)
            v_c_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Horizontal margin"), _
        DescriptionAttribute("Grid horizontal margin")> _
    Public Property m_grid() As Double
        Get
            Return v_m_grid
        End Get
        Set(ByVal value As Double)
            v_m_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Vertical margin"), _
        DescriptionAttribute("Grid vertical margin")> _
    Public Property v_grid() As Double
        Get
            Return v_v_grid
        End Get
        Set(ByVal value As Double)
            v_v_grid = value
        End Set
    End Property
    <CategoryAttribute("Grid"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute(""), _
        DesignOnly(False), _
        DisplayName("Text height"), _
        DescriptionAttribute("Grid text height")> _
    Public Property t_grid() As Double
        Get
            Return v_t_grid
        End Get
        Set(ByVal value As Double)
            v_t_grid = value
        End Set
    End Property

#End Region
#Region "Excel preferences"
    <CategoryAttribute("Excel"), _
        Browsable(True), _
        [ReadOnly](False), _
        BindableAttribute(False), _
        DefaultValueAttribute("%USERHOME%"), _
        DesignOnly(False), _
        DisplayName("Excel directory"), _
        DescriptionAttribute("Name of directory for Excel report output"), _
        Editor(GetType(System.Windows.Forms.Design.FolderNameEditor), GetType(System.Drawing.Design.UITypeEditor))> _
    Public Property p_excl() As String
        Get
            Return v_p_excl
        End Get
        Set(ByVal value As String)
            v_p_excl = value
        End Set
    End Property
    <CategoryAttribute("Excel"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Title colour"), _
       DescriptionAttribute("Colour of title row")> _
    Public Property c_texc() As Color
        Get
            Return v_c_texc
        End Get
        Set(ByVal value As Color)
            v_c_texc = value
        End Set
    End Property
    <CategoryAttribute("Excel"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Header colour"), _
       DescriptionAttribute("Colour of header row")> _
    Public Property c_hexc() As Color
        Get
            Return v_c_hexc
        End Get
        Set(ByVal value As Color)
            v_c_hexc = value
        End Set
    End Property
#End Region
#Region "General preferences"
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Preferences file name"), _
       DescriptionAttribute("Name of XML file specifying these preferences")> _
    Public Property g_file() As String
        Get
            Return v_file
        End Get
        Set(ByVal value As String)
            v_file = value
        End Set
    End Property
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("RCMS layer group name"), _
       DescriptionAttribute("Name of layer filter group for all RCMS layers")> _
    Public Property g_clds() As String
        Get
            Return v_g_clds
        End Get
        Set(ByVal value As String)
            v_g_clds = value
        End Set
    End Property
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("Interface version"), _
       DescriptionAttribute("Interface version string")> _
    Public Property x_vist() As String
        Get
            Return v_x_vist
        End Get
        Set(ByVal value As String)
            v_x_vist = value
        End Set
    End Property
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("V9 rule-set version"), _
       DescriptionAttribute("V9 rule-set version string")> _
    Public Property x_v9st() As String
        Get
            Return v_x_v9st
        End Get
        Set(ByVal value As String)
            v_x_v9st = value
        End Set
    End Property
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("API job timeout"), _
       DescriptionAttribute("API job timeout (seconds)")> _
    Public Property x_timo() As Integer
        Get
            Return v_x_timo
        End Get
        Set(ByVal value As Integer)
            v_x_timo = value
        End Set
    End Property
    <CategoryAttribute("General"), _
       Browsable(True), _
       [ReadOnly](True), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DisplayName("XRecord name"), _
       DescriptionAttribute("XRecord name")> _
    Public Property d_xrec() As String
        Get
            Return v_d_xrec
        End Get
        Set(ByVal value As String)
            v_d_xrec = value
        End Set
    End Property
#End Region
#Region "Methods"
    Public Sub SavePreferences()
        Dim s As New RCMS_Preferences_Serial
        s.SavePreferences(Me)
    End Sub
    Public Sub LoadPreferences()
        Dim s As New RCMS_Preferences_Serial
        s.LoadPreferences(Me)
    End Sub
#End Region
End Class
